N = int(input())
heights = input().split(" ")
for h in range(0, len(heights)):
heights[h] = int(heights[h])
diffs = []
for h in range(0, len(heights)-1):
diff = heights[h] - heights[h+1]
if diff < 0: diff *= -1
diffs.append(diff)
extra_diff = heights[0] - heights[-1]
if extra_diff < 0: extra_diff *= -1
diffs.append(extra_diff)
minimal_position = diffs.index(min(diffs))
if minimal_position+1 == len(diffs):
minimal_pair = [minimal_position + 1, 1]
else:
minimal_pair = [minimal_position + 1, minimal_position + 2]
print(minimal_pair[0], minimal_pair[1])
// base template for CP
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float double
#define sz 100005
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define debug cout << "here" << endl;
#define f(i,s,n) for (int i = s; i < n; ++i)
#define endl "\n"
#define br "\n"
#define printMap(mp) for(auto x : mp){cout<<x.first<<" : "<<x.second<<br;}
#define printv(v) for(auto x:v){cout<<x<<" ";}
#define printvv(v) for(auto x:v){{for(auto it:x) cout<<it<<" ";}cout<<br;}
#define readVector(v) f(i,0,v.size()) cin >> v[i];
#define w(t) while(t--)
const int inf = 4.5e18;
#define spc " "
/*
*max_element(arr, arr + n);
int x = min_element(v.begin(),v.end()) - v.begin(); index of min element
string binary = std::bitset<64>(n).to_string(); decimal to binary
stoi(a, 0, 2);-->a is string of 0 and 1 -->gives decimal value
number of bits in number = > (int)log2(num)+1
vector <int> v[n]; // 2D vector of size n => vector<vector<int>> v(n);
bool flag = binary_search(v.begin(),v.end(), search_value);
int index = upper_bound(v.begin(), v.end(), search_value) - v.begin();
int index = lower_bound(v.begin(), v.end(), search_value) - v.begin();
gcd of two numbers = __gcd(a,b)
string line input
cin>>t; cin.ignore(); w(t--){string s; getline(cin,s);}
//string to lower case
transform(s.begin(), s.end(), s.begin(), ::tolower);
// global arr max size
int arr[1e7];
bool arr[1e8];
// inside finction arr max size
int arr[1e6];
bool arr[1e7];
*/
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;cin>>n;
vi v(n); readVector(v);
if(n==2){
cout<<"1 2";
return 0;
}
int idx=0;
int diff = INT_MAX;
f(i,1,n){
int curr_diff = abs(v[i-1] - v[i]);
if(curr_diff < diff){
diff = curr_diff;
idx=i;
}
if(diff==0)break;
}
if(abs(v[n-1] - v[0]) < diff){
cout<<1<<spc<<n;
}
else cout<<idx<<spc<<idx+1;
return 0;
}
1633C - Kill the Monster | 1611A - Make Even |
1030B - Vasya and Cornfield | 1631A - Min Max Swap |
1296B - Food Buying | 133A - HQ9+ |
1650D - Twist the Permutation | 1209A - Paint the Numbers |
1234A - Equalize Prices Again | 1613A - Long Comparison |
1624B - Make AP | 660B - Seating On Bus |
405A - Gravity Flip | 499B - Lecture |
709A - Juicer | 1358C - Celex Update |
1466B - Last minute enhancements | 450B - Jzzhu and Sequences |
1582C - Grandma Capa Knits a Scarf | 492A - Vanya and Cubes |
217A - Ice Skating | 270A - Fancy Fence |
181A - Series of Crimes | 1638A - Reverse |
1654C - Alice and the Cake | 369A - Valera and Plates |
1626A - Equidistant Letters | 977D - Divide by three multiply by two |
1654B - Prefix Removals | 1654A - Maximum Cake Tastiness |